//
//  MarkaModel.swift
//  Automobile
//
//  Created by erkebulan elzhan on 7/31/20.
//  Copyright © 2020 erkebulan elzhan. All rights reserved.


import Foundation


struct ModelModel: Decodable, ModelCellData {
    
    var model: Model
    var id: Int {
        return model.id
    }
    var postfix: String? = ""
    var name: String {
        return model.name_ru
    }
    var isSelected: Bool = false
    
    enum CodingKeys: String, CodingKey {
        case id
        case name_ru
        case ext
    }
    
    init(from decoder: Decoder) throws {
        let values = try decoder.container(keyedBy: CodingKeys.self)
        let _model = Model(id: try values.decode(Int.self, forKey: .id),
                           ext: try values.decode(Int.self, forKey: .ext),
                           name_ru: try values.decode(String.self, forKey: .name_ru))
        self.model = _model
    }
}
